#include<bits/stdc++.h>
#include<cstdio>
using namespace std;

int t,a[20][4],b[20],c[20],n,maxn=-1;
int total,ans;

void dfs(int x){
    if(x==n+1){
        memset(c,0,sizeof(c));
        for(int i=1;i<=n;i++){
            for(int j=i-1;j>=1;j--){
                if(a[j][2]==a[i][2]){
                    if(a[i][1]==a[j][1]) c[i]=a[i][1];
                    break;
                }
            }

        }
        total=0;
        for(int i=1;i<=n;i++) total+=c[i];
        ans=max(total,ans);
        return ;
    }
    a[x][2]=0;
    dfs(x+1);
    a[x][2]=1;
    dfs(x+1);
}



int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    cin>>t;
    while(t>=1){
        bool special=true;
        t--;
        cin>>n;
        for(int i=1;i<=n;i++){
            cin>>a[i][1];
            b[a[i][1]]++;
            maxn=max(maxn,a[i][1]);
        }
        for(int i=1;i<=maxn;i++){
            if(b[i]>=2) special=false;
        }
        if(special==true){
            cout<<0<<endl;
            special=false;
        }
        else{
            dfs(1);
            cout<<ans<<endl;
        }
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}
